angular.module('bw.services')
    .factory('appointmentService', ['$resource', 'ENV', function($resource, ENV) {
        var resource = $resource(ENV.api, {}, {
            getTripsList: {
                method: 'POST', //输入用户信息获取航班信息
                url: ENV.api + "Trips/GetTripsList"
            },
            sureAppointment: {
                method: 'POST', //确认预约 
                url: ENV.api + "BookingList/AddBookingByClearPort"
            },
            sureAppointmentEnter: {
                method: 'POST', //确认预约 
                url: ENV.api + "BookingList/AddEnterPortPickupOrder"
            },
            getOrderItems: {
                method: 'POST', //获取该微信帐号的历史预约信息
                isLoading:false,
                url: ENV.api + "BookingList/GetOrderItems"
            },
            cancelAppointment: {
                method: 'POST', //取消指定预约订单号
                url: ENV.api + "PickupOrderList/CanceledBooking"
            },
            getAppointmentInfo: {
                method: 'GET', //查询详情
                isLoading:false,
                url: ENV.api + "BookingList/GetBookingInfo"
            },
            getCityList: {
                method: 'GET', //查询城市列表
                url: ENV.api + "Trips/GetCityList"
            },
            getAppStatus: {
                method: 'GET', //获取订单状态【定时获取】
                isLoading:false,
                url: ENV.api + "PickupOrderList/GetBookingStatus"
            },
            sureArived: {
                method: 'GET', //确认已到达
                url: ENV.api + "PickupOrderList/ConfirmPickupOrder"
            },
            getWxSign:{
                method:'GET',//获取微信sign
                url:ENV.api+"Weixin/GetSignature?url="+encodeURIComponent(location.href.split('#')[0])
            },
            getLocationByBaidu:{
                method:'GET',
                url:ENV.api+"Trips/GetAddressByCoordinate?ak="+ENV.baiduMap.ak
            },
            sureGetOn:{//乘客确认上车
                method:'GET',
                url:ENV.api+"Port/ConfirmAboard"
            }
        });
        return {
            /**
             * [getTripsList description]
             *
             * @author  wei.liu@ritetrek.com
             * @DateTime 2017-01-18T13:45:04+0800
             * @param    {[type]}                 params   [description]
             * @param    {Function}               callback [description]
             * @return   {[type]}                          [description]
             */
            getTripsList: function(params, callback) {
                return resource.getTripsList(null, param(params), function(response) {
                    callback && callback(response);
                });
            },
            /**
             * [GetCityList description]
             *
             * 获取包含机构的城市列表
             * @author  wei.liu@ritetrek.com
             * @DateTime 2016-07-25T13:43:47+0800
             * @param    {Function}               callback [description]
             */
            sureAppointment: function(params, callback) {
                return resource.sureAppointment(null, param(params), function(response) {
                    callback && callback(response);
                });
            },
            /**
             * 接机预约
             * @author duantingting@bestwise.cc 2017-02-08
             * @param  {[type]}   params   [description]
             * @param  {Function} callback [description]
             * @return {[type]}            [description]
             */
            sureAppointmentEnter: function(params, callback) {
                return resource.sureAppointmentEnter(null, param(params), function(response) {
                    callback && callback(response);
                });
            },
            /**
             * [getOrderItems description]
             *
             * @author  wei.liu@ritetrek.com
             * @DateTime 2017-01-18T18:15:26+0800
             * @param    {[type]}                 sn       [description]
             * @param    {[type]}                 openid   [description]
             * @param    {Function}               callback [description]
             * @return   {[type]}                          [description]
             */
            getOrderItems: function(params, callback) {
                return resource.getOrderItems(null, param(params), function(response) {
                    callback && callback(response);
                })
            },
            /**
             * [cancelAppointment description]
             *
             *  取消预约订单
             * @author  wei.liu@ritetrek.com
             * @DateTime 2017-01-19T10:59:01+0800
             * @param    {[type]}                 params   [description]
             * @param    {Function}               callback [description]
             * @return   {[type]}                          [description]
             */
            cancelAppointment: function(params, callback) {
                return resource.cancelAppointment(null, param(params), function(response) {
                    callback && callback(response);
                })
            },
            /**
             * [getResultInfo description]
             * 查询预约详情
             * @author  wei.liu@ritetrek.com
             * @DateTime 2017-01-19T12:48:32+0800
             * @param    {[type]}                 openId    [description]
             * @param    {[type]}                 ImgUrl    [description]
             * @param    {[type]}                 ImgUrl50  [description]
             * @param    {[type]}                 ImgUrl200 [description]
             * @param    {[type]}                 ImgUrl500 [description]
             * @param    {Function}               callback  [description]
             * @return   {[type]}                           [description]
             */
            getAppointmentInfo: function(params, callback) {
                return resource.getAppointmentInfo(params, null, function(response) {
                    callback && callback(response);
                })
            },
            /**
             * [getCityList description]
             *
             *  获取城市列表
             * @author  wei.liu@ritetrek.com
             * @DateTime 2017-01-22T11:20:20+0800
             * @param    {[type]}                 params   [description]
             * @param    {Function}               callback [description]
             * @return   {[type]}                          [description]
             */
            getCityList: function(params, callback) {
                return resource.getCityList(params, null, function(response) {
                    callback && callback(response);
                })
            },
            /**
             * [getAppStatus description]
             *
             * 获取订单的状态信息
             * @author  wei.liu@ritetrek.com
             * @DateTime 2017-01-22T11:47:43+0800
             * @param    {[type]}                 params   [description]
             * @param    {Function}               callback [description]
             * @return   {[type]}                          [description]
             */
            getAppStatus: function(params, callback) {
                return resource.getAppStatus(params, null, function(response) {
                    callback && callback(response);
                })
            },
            /**
             * [getAppStatus description]
             *
             * @author  wei.liu@ritetrek.com
             * @DateTime 2017-01-23T14:00:31+0800
             * @param    {[type]}                 params   [description]
             * @param    {Function}               callback [description]
             * @return   {[type]}                          [description]
             */
            sureArived: function(params, callback) {
                return resource.sureArived(params, null, function(response) {
                    callback && callback(response);
                })
            },
            /**
             * [getWxSign description]
             * @author duantingting@bestwise.cc 2017-02-07
             * @param  {[type]}   params   [description]
             * @param  {Function} callback [description]
             * @return {[type]}            [description]
             */
            getWxSign:function(params,callback){
                return resource.getWxSign(params, null, function(response) {
                    callback && callback(response);
                })
            },
            getLocationByBaidu:function(params,callback){
                return resource.getLocationByBaidu(params, null, function(response) {
                    callback && callback(response);
                })
            },
            sureGetOn:function(params,callback){
                return resource.sureGetOn(params, null, function(response) {
                    callback && callback(response);
                })
            }
        }
    }]);
